Skip to content

fix: skip duplicate HTTP status lines in ReadResponse#542

Merged
Mzack9999 merged 2 commits into
projectdiscovery:mainfrom
XananasX7:fix/duplicate-status-lines
Jun 16, 2026
Merged

fix: skip duplicate HTTP status lines in ReadResponse#542
Mzack9999 merged 2 commits into
projectdiscovery:mainfrom
XananasX7:fix/duplicate-status-lines

Conversation

@XananasX7

Copy link
Copy Markdown
Contributor

Problem

Some non-compliant servers (e.g. Grandstream HT801 firmware 1.0.13.7) emit the HTTP status line more than once before actual headers:

HTTP/1.0 200 OK\r\n
HTTP/1.0 200 OK\r\n   ← duplicate
Content-Type: text/html\r\n
\r\n

ReadHeader() splits on :. A repeated status line has no :, so parsing fails with:

malformed MIME header: missing colon: "HTTP/1.0 200 OK"

This error propagates to Nuclei as a fatal request error even under unsafe: true, preventing matchers from ever running.

Fix

After reading the first status line in ReadResponse(), peek ahead and discard any additional lines that start with HTTP/ before entering the header-reading loop. The change is minimal (< 15 lines) and touches only the one code path.

Tests

Two new regression tests added to client/reader_test.go:

  • TestReadResponseDuplicateStatusLines — double status line with a body
  • TestReadResponseTripleStatusLines — triple status line

All existing tests continue to pass (go test ./...).

Related

Some non-compliant servers (e.g. Grandstream HT801 firmware 1.0.13.7)
emit the HTTP status line more than once before the actual headers:

  HTTP/1.0 200 OK\r\n
  HTTP/1.0 200 OK\r\n   <- duplicate
  Content-Type: text/html\r\n
  ...

The rawhttp parser passes header lines to ReadHeader(), which splits on
':'. A duplicate status line has no ':', so parsing fails with:

  malformed MIME header: missing colon: "HTTP/1.0 200 OK"

This propagates to Nuclei as a fatal request error even under
unsafe: true, preventing matchers from ever running.

Fix: after reading the first status line in ReadResponse(), peek ahead
and discard any additional lines that start with 'HTTP/' before
entering the header-reading loop.

Adds regression tests for duplicate and triple status lines.

Fixes projectdiscovery#541
Related: projectdiscovery/nuclei#7363
@Mzack9999 Mzack9999 self-requested a review June 16, 2026 20:41
@Mzack9999 Mzack9999 merged commit c41b464 into projectdiscovery:main Jun 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Parser fails on duplicate HTTP status lines (malformed MIME header error)

2 participants